#include<vector>
#include<queue>
#include<condition_variable>
#include<functional>
#include<thread>
#include<mutex>
#include<utility>
#include<set>
using namespace std;
class threadpool{

public:

threadpool(int num);//num线程池的线程数
~threadpool();
//模板函数
template<class F,class... Arges>
void addtasks(F && f,Arges &&... arges)//添加任务进入任务池
{
    function<void()> task=bind(forward<F>(f),forward<Arges>(arges)...);
    {
        unique_lock<std::mutex> lock(mutex);
        tasks.emplace(task);
    }
    condition.notify_one();
}
private:

vector<thread>works;//线程池
queue<function<void()>>tasks;//任务池
mutex task_mutex;//任务锁
condition_variable condition;//任务条件锁
};

